﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace TankeWar.Sprites
{
    internal class PlayerSprite : TankeSprite
    {
        public PlayerSprite(Game game)
            : base(game) { }

        protected override void Init(Game game)
        {
            this.TankeTexture2d = game.Content.Load<Texture2D>("PlayerTanke");
            TankeRect = new Rectangle(0, 0, TankeTexture2d.Height, TankeTexture2d.Width / 4);
        }        

        protected override void Move()
        {
            KeyboardState KeyState = Keyboard.GetState();

            if (KeyState.IsKeyDown(Keys.W))
            {
                TankeRect.Y -= MoveSpeed;
                Direction = TankeDirection.Up;
            }
            else if (KeyState.IsKeyDown(Keys.S))
            {
                TankeRect.Y += MoveSpeed;
                Direction = TankeDirection.Down;
            }
            else if (KeyState.IsKeyDown(Keys.A))
            {
                TankeRect.X -= MoveSpeed;
                Direction = TankeDirection.Left;
            }
            else if (KeyState.IsKeyDown(Keys.D))
            {
                TankeRect.X += MoveSpeed;
                Direction = TankeDirection.Right;
            }
        }
    }
}
